import rxAjax from '@/assets/js/ajax.js';

export const OsInstApi = {};

OsInstApi.baseUrl= '/api-user/user/org/osInst';
OsInstApi.exportUrl= OsInstApi.baseUrl + '/listExport';

OsInstApi.query=function (parameter) {
  var url= OsInstApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then (res => {
    return res.result
  })
}

/**
 * 获取单记录
 * @param pkId
 * @returns {*}
 */
OsInstApi.get =function(pkId) {
  var url= OsInstApi.baseUrl + '/get?pkId=' + pkId;
  return rxAjax.get(url);
}

OsInstApi.save =function(parameter) {
  var url= OsInstApi.baseUrl + '/save';
  return rxAjax.postJson(url,parameter);
}

OsInstApi.del =function(parameter) {
  var url= OsInstApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}

OsInstApi.getList = function () {
  var url = OsInstApi.baseUrl + '/getList';
  return rxAjax.get(url);
}

OsInstApi.saveSelectInst=function(data){
  var url = OsInstApi.baseUrl + '/saveSelectInst';
  return rxAjax.postJson(url,data);
}

OsInstApi.quitOrCancel=function(instId,moreInstStatus){
  var url = OsInstApi.baseUrl + '/quitOrCancel?instId='+instId+'&moreInstStatus='+moreInstStatus;
  return rxAjax.get(url);
}

// 管理员禁用机构内用户
OsInstApi.updateUserStatus=function(instId,userId,status){
    var url = OsInstApi.baseUrl + '/updateUserStatus?instId='+instId+'&userId='+userId+'&status='+status;
    return rxAjax.get(url);
}

OsInstApi.agreeOrRefuse=function(data){
  var url = OsInstApi.baseUrl + '/agreeOrRefuse';
  return rxAjax.postJson(url,data);
}

OsInstApi.getMyApplyList=function(){
  var url = OsInstApi.baseUrl + '/getMyApplyList';
  return rxAjax.get(url);
}

OsInstApi.updateCurUserTenantId=function(tenantId){
  var url = OsInstApi.baseUrl + '/updateCurUserTenantId?tenantId='+tenantId;
  return rxAjax.get(url);
}

OsInstApi.updateCurUserCompanyId=function(companyId){
  var url = OsInstApi.baseUrl + '/updateCurUserCompanyId?companyId='+companyId;
  return rxAjax.get(url);
}

OsInstApi.updateCurUserSubCompanyId=function(companyId){
  var url = OsInstApi.baseUrl + '/updateCurUserSubCompanyId?companyId='+companyId;
  return rxAjax.get(url);
}

export  default OsInstApi;
